{include file="public/header" /}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class="layui-this">个人信息添加</li>
            <li class="layui-btn"><a href="javascript:void(0)"  onclick="back()" style="color: white">返回上一页</a></li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form form-container" id="formId" action="{:url('add')}" method="post">
                    <div class="layui-form-item">
                        <label class="layui-form-label" for="username">管理员</label>
                        <div class="layui-input-block" >
                            <input type="text" name="username"  id="username" onblur="lose();" class="layui-input" />
                            <div id="usernameCheck" style="display: none;color: red;"></div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" for="pwd">密码</label>
                        <div class="layui-input-block" >
                            <input type="password" name="pwd" id="pwd" value="" onblur="pwdCheck()" required  lay-verify="required" placeholder="请输入新密码(只能是字母，和数字不能小于6个字符)" class="layui-input">
                            <div id="pwdCheck" style="display: none;color: red;"></div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">职位选择</label>
                        <div class="layui-input-block">
                            <select name="selects"  >
                                <option value="0">请选择角色</option>
                                {volist name="result" id="val"}
                                <option value="{$val.id}.{$val.role_name}">{$val.role_name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="submit">提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    function back(){
        history.back()
    }
    /**
     * 后台管理员验证
     */
    function lose(){
        var val=$("#username").val();
        var len=val.length;
        if(len<=1 || len>5){
           $("#usernameCheck").show();
           $("#usernameCheck").html("请填写2位到5位字符");
            $("#usernameCheck").css({color:'red'});
        }else{
            $("#usernameCheck").show();
            $("#usernameCheck").html("输入正确");
            $("#usernameCheck").css({color:'green'});
        }

    }
    /**
     * 密码验证
     */
    function pwdCheck(){
          var val=$("#pwd").val();
          var result=val.match(/^[a-z]+[0-9]/i);
          if(result!=null){
              $("#pwdCheck").show();
              $("#pwdCheck").html("输入正确");
              $("#pwdCheck").css({color:'green'});
          }else{
              $("#pwdCheck").show();
              $("#pwdCheck").html("请输入6位以上的字符以字母开头数字结尾");
              $("#pwdCheck").css({color:'red'});
          }
    }
</script>
{include file="public/footer" /}